<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<%@ page import="com.scalar.chiptrack.utils.ConfigManager" %>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/transactionReportAction.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<HTML>
<HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=windows-1252">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type="text/css" rel="stylesheet">
<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/quickSearch.js"></script>
</HEAD>
<script language="javascript">
    window.onload = init;
    var dateElement = "";
    function openCalendar(dateValue)
    {
        dateElement = dateValue;
        newWindow = window.open('<%=chipTracContext%>/jsp/includes/calendar.html','optionsPopup','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=no,width=180,height=440,resizable=no');
        newWindow.moveTo(550,180);
        newWindow.focus();
    }

    function assignDate(passedValue)
    {
        dateElement.value=passedValue;
        window.focus();
    }
    function init()
    {
        <logic:equal value="true" property="byLot" name="detailedTransactionReportForm">
            qs_1 = new QuickSearch(document.detailedTransactionReportForm.processStepId, document.detailedTransactionReportForm.qs1, false);
        </logic:equal>
    }
    function validatePage()
    {
        var form = document.detailedTransactionReportForm
        errMsg = '';

        var pa	= document.getElementById("errors")
        pa.innerHTML = "";
        if(chkDate(form.fromDate.value,'From-Date','Y') == false)
        {
            pa.innerHTML = errMsg;
            form.fromDate.focus();
            return false;
        }

        if(chkDate(form.toDate.value,'To-Date','Y') == false)
        {
            pa.innerHTML = errMsg;
            form.toDate.focus();
            return false;
        }
        if(form.fromDate.value!='' && form.toDate.value!='')
        {
            if (!validateDateOut(formatDateAsMMDDYYYY(form.fromDate.value),formatDateAsMMDDYYYY(form.toDate.value)))
            {
                pa.innerHTML = "<li>To Date cannot be less than From Date";
                form.toDate.focus();
                return false;
            }
        }
        /*var productCtrl = form.processStepId;
        if ( productCtrl != null && productCtrl.value == 0 )
        {
            pa.innerHTML = "<li>Please select a Part Number";
            productCtrl.focus();
            return false;
        }*/
        return true;
    }
    function submitReport( )
    {
        var form = document.detailedTransactionReportForm;
        if ( validatePage() )
        {
            var processType;
            if( form.processType[0].checked )
            {
                processType = form.processType[0].value;
            }
            else if( form.processType[1].checked )
            {
                processType = form.processType[1].value;
            }
            else if( form.processType[2].checked )
            {
                processType = form.processType[2].value;
            }
            else if( form.processType[3].checked ) //Tape & Reel
            {
                processType = escape(form.processType[3].value);
            }
            else if( form.processType[4].checked )
            {
                processType = form.processType[4].value;
            }
            else if( form.processType[5].checked )
            {
                processType = form.processType[5].value;
            }
            var processStepId = 0;
            if ( form.byLot.checked )
                processStepId = form.processStepId.value;
            var newWindow;
            /*var url = '<%=chipTracContext%>/detailedTransactionReportAction.do?action=generateDetailedTransactionReportXls&baseProductId='+ form.baseProductId.value +'&fromDate='+form.fromDate.value + '&toDate='+form.toDate.value + '&processType=' + processType + '&byLot=' + form.byLot.checked+'&processStepId=' + processStepId+'&vendorName='+escape(form.vendorName.value);*/
            form.action ='<%=chipTracContext%>/detailedTransactionReportAction.do?action=generateDetailedTransactionReportXls&baseProductId='+ form.baseProductId.value +'&fromDate='+form.fromDate.value + '&toDate='+form.toDate.value + '&processType=' + processType + '&byLot=' + form.byLot.checked+'&processStepId=' + processStepId+'&vendorName='+escape(form.vendorName.value);
            /*newWindow = window.open ( url, 'TransactionReport', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=450,height=150,resizable=yes');*/
            form.submit();
        }
    }
    function loadFormValues()
    {
        var form = document.detailedTransactionReportForm;
        form.action = "<%=chipTracContext%>/detailedTransactionReportAction.do";
        form.submit();
        return true;
    }
    function onBaseProductChange()
    {
        var form = document.detailedTransactionReportForm;
        var byLotCtrl = form.byLot;
        if ( byLotCtrl.checked )
        {
            loadFormValues();
        }
    }
    function onProcessTypeClick()
    {
        var form = document.detailedTransactionReportForm;
        loadFormValues();
    }

</script>
<BODY bgColor=#ffffff leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">
<!-- Top Header Start-->
<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->
<TABLE cellSpacing="0" cellPadding="0" width="100%" border="0">
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>
    <!-- Side Navigation start -->
    <%@ include file="/jsp/operations/reports_side_menu.jsp" %>
    <!-- end of the side navigations -->
    </TD>
    <TD bgcolor="#ffffff">
        <IMG height="9" src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="8"></TD>
        <TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width="2"></TD>
        <TD valign="top" width="100%">
        <IMG height="1" src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width="500" border="0">
        <BR>
        <html:form name="detailedTransactionReportForm" type="com.scalar.chiptrack.operations.reports.actions.DetailedTransactionReportAction" action="/detailedTransactionReportAction.do">
        <TABLE border="0" width="100%" align="center">
            <TR><TD colspan="6" class="NArialW" align="center">Detail Transaction Report</TD></TR>
            <TR><TD colspan="6">&nbsp;</TD></TR>
            <TR><TD width="12%" >&nbsp;</TD><TD colspan="6" class='NArialL' align="left"><strong><FONT id="errors" color='FF0000'>&nbsp;</FONT></strong></TD></TR>
            <TR>
                <TD>&nbsp;</TD>
                <TD colspan="6" align="left">
                  <chiptrack:info styleClass="NArialL" />
                  <chiptrack:errors styleClass="NArialL" />
                  <chiptrack:messages type="info" styleClass="NArialL" />&nbsp;
                </TD>
            </TR>
            <TR>
                <TD colspan="6">
                    <TABLE align="center" border="0" width="100%" cellspacing="3" cellpadding="2">
                        <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top' align = "right">Base Product :</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:select property="baseProductId" styleClass="txfield" onchange="onBaseProductChange();">
                                    <html:option value="0">Select Base Product</html:option>
                                    <html:options collection="baseProductList" property="value" labelProperty="label"/>
                                </nested:select>
                            </TD>

                            <TD width="15%" class="NArialL" valign = 'top' align = "center">&nbsp;</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>&nbsp;</TD>
                            <TD width="15%" >&nbsp;</TD>
                        </TR>
                        <TR>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top' align = "right">From Date<font color=red>*</font> :</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:text property="fromDate" size="12" styleClass="txfield"/>
                                <a href="javascript:openCalendar(document.detailedTransactionReportForm.fromDate)"onmouseover="window.status='Click to Select From Date';return true"onmouseout="window.status='';return true"title="Click here to Select From Date">
                                    <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18>
                                </a>
                            </TD>

                            <TD width="15%" class="NArialL" valign = 'top' align = "right">To Date<font color=red>*</font> :</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:text property="toDate" size="12" styleClass="txfield"/>
                                <a href="javascript:openCalendar(document.detailedTransactionReportForm.toDate)"onmouseover="window.status='Click to Select From Date';return true"onmouseout="window.status='';return true"title="Click here to Select From Date">
                                    <img border="0" src="<%=chipTracContext%>/jsp/includes/images/date_selector.gif" height=18 width=18>
                                </a>
                            </TD>
                            <TD width="15%" >&nbsp;</TD>
                        </TR>
                        <tr>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top' align = "right">Process Type :</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <table>
                                    <tr>
                                        <td class="NArialL"><nested:radio property="processType" value="Die Bank" styleClass="txfield" onclick="onProcessTypeClick();"/>&nbsp;Die Bank</td>
                                    </tr>
                                    <tr>
                                        <td class="NArialL"><nested:radio property="processType" value="Assembly" styleClass="txfield" onclick="onProcessTypeClick();"/>&nbsp;Assembly</td>
                                    </tr>
                                    <tr>
                                        <td class="NArialL"><nested:radio property="processType" value="FT" styleClass="txfield" onclick="onProcessTypeClick();"/>&nbsp;Test</td>
                                    </tr>
                                    <tr>
                                        <td class="NArialL"><nested:radio property="processType" value="Tape & Reel" styleClass="txfield" onclick="onProcessTypeClick();"/>&nbsp;Tape & Reel</td>
                                    </tr>
                                    <tr>
                                        <td class="NArialL"><nested:radio property="processType" value="FG" styleClass="txfield" onclick="onProcessTypeClick();"/>&nbsp;FG</td>
                                    </tr>
                                    <tr>
                                        <td class="NArialL"><nested:radio property="processType" value="RMA" styleClass="txfield" onclick="onProcessTypeClick();"/>&nbsp;RMA</td>
                                    </tr>
                                </table>
                            </TD>

                            <TD width="15%" class="NArialL" valign = 'top' align = "right"> Vendor Name :</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:select property="vendorName" styleClass="txfield">
                                    <html:option value="0">Select Vendor</html:option>
                                    <html:options collection="vendorList" property="label" labelProperty="label"/>
                                </nested:select>
                            </TD>
                            <TD width="15%" >&nbsp;</TD>                            
                        </tr>

                        <tr>
                            <td width="10%" class="NArialL" > &nbsp;</td>
                            <TD width="35%" class="NArialL" valign = 'top' colspan='2' align='left'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<nested:checkbox property="byLot" styleClass="txfield" onclick="loadFormValues();"/>&nbsp; By Lot</TD>
                            <!--<TD width="20%" >&nbsp;</TD>-->
                        <nested:equal value="true" property="byLot">
                            <TD width="15%" class="NArialL" align = "right">
                                Quick Search Part Number:
                            </td>
                            <td class="NArialL"  width="20%">
                                <input type="text" name="qs1" class="txfield" size='22' onkeyup='quickSearch(qs_1)'/>
                            </td>
                            <TD width="15%" >&nbsp;</TD>
                        </tr>
                        <tr>
                            <TD width="10%">&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top'>&nbsp;</TD>
                            <TD width="20%" >&nbsp;</TD>
                            <TD width="15%" class="NArialL" valign = 'top' align = "right">Part Number:</TD>
                            <TD width="20%" class="NArialL" valign = 'top'>
                                <nested:select property="processStepId" styleClass="txfield" >
                                    <html:option value="0">Select Part Number</html:option>
                                    <html:options collection="productList" property="value" labelProperty="label"/>
                                </nested:select>
                            </td>
                            <TD width="15%" >&nbsp;</TD>
                        </tr>
                        </nested:equal>
                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></TD></TR>

                        <TR>
                            <TD colspan="4" align=right valign="top">
                                <a href="javascript:submitReport();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/submit.gif" width="53" height="17" onmouseover="window.status='Click to Generate Transaction Report';return true" onmouseout="window.status='';return true" title='Click to Generate Transaction Report'></a>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                                <a href="javascript:document.detailedTransactionReportForm.reset();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/reset.gif" width="53" height="17" onmouseover="window.status='Click to reset search';return true" onmouseout="window.status='';return true" title="Click here to reset search"></a>
                                &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                            </TD>
                            <td colspan=2 valign="top">&nbsp;</td>
                        </TR>
                        <TR><TD colspan="6"><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></TD></TR>
                    </TABLE>
                </TD>
            </TR>
        </TABLE>
        </html:form>
    </TR>
</TABLE>
<!-- Footer starts here -->
<%@ include file="/jsp/includes/footer.jsp" %>
<!-- footer end here -->
</BODY>
</HTML>
